home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
st80_pr4.lha
/
st80_pre4
/
MoDE
/
Windowing-Shan.st
< prev
Wrap
Text File
|
1993-07-24
|
20KB
|
853 lines
TextLabel subclass: #ShrunkenWText
instanceVariableNames: 'window '
classVariableNames: ''
poolDictionaries: ''
category: 'Windowing-Shan'!
!ShrunkenWText methodsFor: 'private'!
window: aWindow
"Shan June 15, 1989"
window _ aWindow.
self text: aWindow title! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
ShrunkenWText class
instanceVariableNames: ''!
!ShrunkenWText class methodsFor: 'instance creation'!
window: aWindow
^self new window: aWindow! !
SemanticObject subclass: #TitleBar
instanceVariableNames: 'window title '
classVariableNames: ''
poolDictionaries: ''
category: 'Windowing-Shan'!
!TitleBar methodsFor: 'attach'!
attachTo: aWindow
"Attach the title bar to aWindow (semObj). Assuming the window's extent has
been instantiated. Shan May 11, 1989"
aWindow mode addSubMode: mode at: 0 @ 0.
mode window: (mode window width: aWindow mode window width).
target1 _ aWindow! !
!TitleBar methodsFor: 'title'!
title: s
| dispObj dispText|
title _ s.
dispObj _ mode displayObject.
dispText _ s asDisplayText.
dispText align: dispText boundingBox center with: dispObj boundingBox center.
dispObj clear. "Shan January 2, 1990"
dispObj absAdd: dispText! !
!TitleBar methodsFor: 'controller-msg'!
moveWindow: e
"Follow the cursor to move the window. Ask the window semObj to
do it. Shan June 4, 1989"
"target1 mode moveToFront."
mode controller highlight.
"To support the SNATextWindow. When the user click on the titlebar
to bring the window to top, also highlight the bar. Shan 16 May
1990"
target1 move!
rename: e
"Shan 1 June 1990"
| titleString |
self eventQueue disable.
titleString := FillInTheBlank request: 'New title' initialAnswer: ''.
self eventQueue enable.
titleString = '' ifTrue: [^nil].
target1 title: titleString.!
toFront: e
"Shan 25 May 1990"
target1 mode obscuringRects size > 0 ifTrue: [target1 mode toFront]! !
!TitleBar methodsFor: 'MMS-initializations'!
setUpAppearance
"Shan June 6, 1989"
| dispObj |
super setUpAppearance.
mode extent: 200@28. "Shan July 21, 1989"
dispObj _ mode displayObject.
dispObj borderWidth: 2.
mode scaledBackground.
dispObj insideColor: Form lightGray.
"Shan July 21, 1989"
mode highlightDispObj: (dispObj copy insideColor: Form darkGray)!
setUpController
"Shan June 6, 1989"
| ctrl erDict |
ctrl _ OpaqueController1 new.
erDict _ ctrl eventResponses deepCopy.
erDict at: #leftButtonDown put: #moveWindow:.
erDict at: #leftButtonUp put: #toFront:.
erDict at: #middleButtonDoubleClick put: #rename:. "Shan 1 June 1990"
ctrl eventResponses: erDict.
mode controller: ctrl!
setUpMode
"Shan June 9, 1989"
| rs |
super setUpMode.
rs _ ResizeStyle new.
rs originX: #fixed.
rs originY: #fixed.
rs extentY: #fixed.
rs cornerX: #fixed.
mode resizeStyle: rs! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
TitleBar class
instanceVariableNames: ''!
!TitleBar class methodsFor: 'instance creation'!
title: s
"Shan June 6, 1989"
^self new title: s! !
TitleBar subclass: #MacTitleBar
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Windowing-Shan'!
!MacTitleBar methodsFor: 'MMS-initializations'!
setUpAppearance
"Shan June 6, 1989"
| dispObj line hDispObj |
super setUpAppearance.
dispObj _ mode displayObject.
dispObj borderWidth: 2.
dispObj insideColor: Form white.
mode highlightDispObj: dispObj deepCopy.
hDispObj _ mode highlightDispObj.
"This must be done after the extent and the borderWidth have been
set. No for the bWidth now. Shan December 1, 1989"
mode scaledBackground.
line _ MMSLine
from: 0 @ 5
to: 200 @ 5
width: 1
color: Form black.
hDispObj relAdd: line.
line _ MMSLine
from: 0 @ 8
to: 200 @ 8
width: 1
color: Form black.
hDispObj relAdd: line.
line _ MMSLine
from: 0 @ 11
to: 200 @ 11
width: 1
color: Form black.
hDispObj relAdd: line.
line _ MMSLine
from: 0 @ 14
to: 200 @ 14
width: 1
color: Form black.
hDispObj relAdd: line.
line _ MMSLine
from: 0 @ 17
to: 200 @ 17
width: 1
color: Form black.
hDispObj relAdd: line.
hDispObj makeFaster! !
TitleBar subclass: #ShadedTitleBar
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Windowing-Shan'!
!ShadedTitleBar methodsFor: 'title'!
title: s
"Shan 10 May 1990"
super title: s.
"Draw the shadows."
self setUpAppearance.! !
!ShadedTitleBar methodsFor: 'MMS-initializations'!
setUpAppearance
"Shan September 5, 1989"
| dispObj line |
super setUpAppearance.
mode extent: 400@28.
dispObj _ mode displayObject.
dispObj borderWidth: 2.
"This must be done after the extent and the borderWidth have been
set. "
mode scaledBackground.
dispObj insideColor: Form lightGray.
line _ MMSLine
from: 2 @ 2
to: 400 @ 2
width: 2
color: Form white.
dispObj absAdd: line.
line _ MMSLine
from: 2 @ 25
to: 400 @ 25
width: 1
color: Form black.
dispObj absAdd: line.
line _ MMSLine
from: 2 @ 2
to: 2 @ 28
width: 2
color: Form white.
dispObj absAdd: line.
line _ MMSLine
from: 396 @ 3
to: 396 @ 28
width: 1
color: Form black.
dispObj absAdd: line.
line _ MMSLine
from: 397 @ 2
to: 397 @ 28
width: 1
color: Form black.
dispObj absAdd: line.
dispObj makeFaster.
mode highlightDispObj: nil! !
SemanticObject subclass: #ShrunkenWindow
instanceVariableNames: 'window '
classVariableNames: ''
poolDictionaries: ''
category: 'Windowing-Shan'!
!ShrunkenWindow methodsFor: 'MMS-initializations'!
defaultMMSControllerClass
"Shan August 24, 1989"
^MoveImageController1!
defaultModeClass
"Shan August 24, 1989"
^ModeGroup!
setUpController
"Shan August 24, 1989"
| ctrl erDict |
super setUpController.
ctrl _ mode controller.
erDict _ ctrl eventResponses deepCopy.
erDict at: #leftButtonDoubleClick put: #expand:.
ctrl eventResponses: erDict! !
!ShrunkenWindow methodsFor: 'private'!
window: aWindow
"Shan August 24, 1989"
| pictureMode text |
window _ aWindow.
pictureMode _ FixedImageMode new.
pictureMode semanticObject: SemanticObject new. "Shan 29 May 1990"
pictureMode imageForm: MMSOpaqueForm sheet.
text _ ShrunkenWText window: aWindow.
ModeGrouper parent: mode centerVerticalChildren: (OrderedCollection with: pictureMode with: text mode)! !
!ShrunkenWindow methodsFor: 'controller-msg'!
expand: e
"Tell the window to expand. Shan August 24, 1989"
Display zoom: mode unclippedDisplayBox to: window mode unclippedDisplayBox.
window mode moveToFront.
window mode mapAndDisplay! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
ShrunkenWindow class
instanceVariableNames: ''!
!ShrunkenWindow class methodsFor: 'instance creation'!
window: aWindow
^self new window: aWindow! !
SemanticObject subclass: #ControlBox
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Windowing-Shan'!
!ControlBox methodsFor: 'MMS-initializations'!
setUpAppearance
"Shan July 21, 1989"
super setUpAppearance.
mode extent: 18@18! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
ControlBox class
instanceVariableNames: ''!
!ControlBox class methodsFor: 'instance creation'!
client: aWindow
"aWindow must be an instance of Window class. Shan June 7, 1989"
^self new client: aWindow! !
ControlBox subclass: #ResizeBox
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Windowing-Shan'!
!ResizeBox methodsFor: 'MMS-initializations'!
setUpAppearance
"Shan June 6, 1989"
| dispObj |
super setUpAppearance. "Shan July 21, 1989"
dispObj _ mode displayObject.
dispObj borderWidth: 2.
dispObj insideColor: Form white.
dispObj relAdd: (Quadrangle
region: (4 @ 4 extent: 8 @ 9)
borderWidth: 1
borderColor: Form black
insideColor: Form white).
dispObj relAdd: (Quadrangle
region: (2 @ 2 extent: 7 @ 7)
borderWidth: 1
borderColor: Form black
insideColor: Form white).
dispObj makeFaster!
setUpController
"Shan June 6, 1989"
| ctrl erDict |
ctrl _ MController new.
erDict _ ctrl eventResponses deepCopy.
erDict at: #leftButtonDown put: #resize:.
ctrl eventResponses: erDict.
mode controller: ctrl!
setUpMode
"Shan June 9, 1989"
| rs |
super setUpMode.
rs _ ResizeStyle new.
rs extentX: #fixed.
rs extentY: #fixed.
rs cornerX: #fixed.
rs cornerY: #fixed.
mode resizeStyle: rs! !
!ResizeBox methodsFor: 'controller-msg'!
resize: e
"Resize the client. See the implementation in MMSController1 for
details. Shan June 8, 1989"
| clientMode frame background event |
clientMode _ target1 mode.
target1 minimumSize = target1 maximumSize ifTrue: [^self].
clientMode controller
resize: #bottomRight
outline: [:frame :mousePoint | frame corner: ((mousePoint max: frame origin + target1 minimumSize)
min: frame origin + target1 maximumSize)]
width: 2
halftone: Form gray.
target1 applicationMode changed: #contentsBoundingBoxMayBeChanged.! !
!ResizeBox methodsFor: 'private'!
client: aWindow
"Shan 15 May 1990"
target1 _ aWindow! !
ControlBox subclass: #ShrinkBox
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Windowing-Shan'!
!ShrinkBox methodsFor: 'controller-msg'!
shrink: e
"Shrink the client into an icon. Shan June 7, 1989"
target1 shrink! !
!ShrinkBox methodsFor: 'MMS-initializations'!
setUpAppearance
"Shan June 6, 1989"
| dispObj |
super setUpAppearance. "Shan July 21, 1989"
dispObj _ mode displayObject.
dispObj borderWidth: 2.
dispObj insideColor: Form white!
setUpController
"Shan June 6, 1989"
| ctrl erDict |
ctrl _ MController new.
erDict _ ctrl eventResponses deepCopy.
erDict at: #leftButtonDown put: #shrink:.
ctrl eventResponses: erDict.
mode controller: ctrl! !
!ShrinkBox methodsFor: 'private'!
client: aWindow
"Attach self to a window. This includes add the mode of self as a
subMode of the window mode and assign the window as the client of
self. Shan June 7, 1989"
aWindow mode addSubMode: mode at: 5 @ 5.
target1 _ aWindow! !
SemanticObject subclass: #Trash
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Windowing-Shan'!
!Trash methodsFor: 'MMS-initializations'!
defaultMMSControllerClass
"Shan July 21, 1989"
^MoveImageController1!
defaultModeClass
"Shan July 21, 1989"
^FixedImageMode!
setUpAppearance
"Shan July 21, 1989"
| dispObj |
super setUpAppearance. "Shan July 21, 1989"
dispObj _ mode displayObject.
dispObj absAdd: MMSOpaqueForm trash.
mode highlightDispObj: (MDisplayObject new borderWidth: 0; absAdd: MMSOpaqueForm openTrash).! !
!Trash methodsFor: 'drag support'!
deHighlightOnTop: e
"Shan July 22, 1989"
mode controller dragDeHighlightOnTop!
dragControllerFor: aSymbol
"Shan July 21, 1989"
| ctrl erDict |
aSymbol == #move
ifTrue:
[ctrl _ MController new.
erDict _ ctrl eventResponses deepCopy.
erDict at: #leftButtonUp put: #trashIt:.
erDict at: #enterMode put: #highlightOnTop:.
erDict at: #leaveMode put: #deHighlightOnTop:.
ctrl eventResponses: erDict.
^ctrl].
^super dragControllerFor: aSymbol!
highlightOnTop: e
"Shan July 22, 1989"
mode controller dragHighlightOnTop!
trashIt: e
"Trash the dragged object. Shan July 21, 1989"
mode deHighlight! !
SemanticObject subclass: #Window
instanceVariableNames: 'shrunkenWindow applicationMode maximumSize minimumSize title titleBar '
classVariableNames: ''
poolDictionaries: ''
category: 'Windowing-Shan'!
!Window methodsFor: 'mode attaching'!
attachModeTo: aMode absAt: p extent: e
"Also attach the shrunkenWindow. Shan August 4, 1989"
super attachModeTo: aMode absAt: p extent: e.
self attachShrunkenWindowTo: aMode "Shan 13 June 1990"!
attachModeTo: aMode at: p extent: e
"Also attach the shrunkenWindow. Shan August 4, 1989"
super attachModeTo: aMode at: p extent: e.
self attachShrunkenWindowTo: aMode "Shan 13 June 1990"!
attachShrunkenWindowTo: aMode
"Also attach the shrunkenWindow. Shan 13 June 1990"
shrunkenWindow attachModeTo: aMode! !
!Window methodsFor: 'expand-shrink'!
initialClose
"The window will initially be open. Do nothing since this is the
default. Shan August 4, 1989"
^self!
initialOpen
"The window will initially be open. Shan August 4, 1989"
mode map.
shrunkenWindow mode unMap!
shrink
"This method close the window into an icon. Shan June 7, 1989"
titleBar mode deHighlight. "Shan July 21, 1989"
mode eraseAndUnMap.
"shrunkenWindow mode superView isNil ifTrue: [mode superView addSubMode: shrunkenWindow mode at: 50 @ 50]. Shan June 15 commented out"
Display zoom: mode unclippedDisplayBox to: shrunkenWindow mode unclippedDisplayBox.
shrunkenWindow mode mapAndDisplay!
shrinkPosition: aPoint
"Shan June 16, 1989"
shrunkenWindow mode origin: aPoint! !
!Window methodsFor: 'access'!
shrunkenWindow
^shrunkenWindow!
shrunkenWindow: w
shrunkenWindow _ w!
title
"Shan 30 May 1990"
title isNil ifTrue: [title _ ''].
^title!
title: aString
"Change the title. Shan 30 May 1990"
title _ aString.
self setUpTitleBar.
self setUpShrunkenWindow!
titleBar: aTitleBar
"Shan September 5, 1989"
titleBar isNil
ifFalse:
[titleBar mode removeFromSuperMode.
titleBar mode release].
titleBar _ aTitleBar title: self title.
titleBar attachTo: self.
titleBar mode moveToBack! !
!Window methodsFor: 'application mode'!
applicationMode
^applicationMode!
applicationMode: applMode
| rs |
applicationMode _ applMode.
mode
addToBackSubMode: applMode
at: mode borderWidth @ 28
extent: mode window extent - (0 @ 26) - (2*mode borderWidth).
applicationMode borderWidth: 0.
rs _ ResizeStyle new. "Shan June 23, 1989"
rs originX: #fixed.
rs originY: #fixed.
rs cornerX: #fixed.
rs cornerY: #fixed.
rs matchViewportWindow: true.
applicationMode resizeStyle: rs.! !
!Window methodsFor: 'positioning'!
move
mode controller moveImage! !
!Window methodsFor: 'setUps'!
setUpResizeBox
"Shan 15 May 1990"
| rBox |
rBox _ ResizeBox client: self.
rBox attachModeTo: mode at: mode window extent - (18 @ 18)!
setUpShrinkBox
"Shan June 7, 1989"
ShrinkBox client: self!
setUpShrunkenWindow
"Shan 30 May 1990"
| pos superM |
shrunkenWindow isNil
ifFalse:
[superM _ shrunkenWindow mode superMode. "Shan 1 June 1990"
pos _ shrunkenWindow mode origin.
shrunkenWindow mode superView isNil ifFalse: ["Come back and fix it. shrunkenW not refreshed."
(shrunkenWindow mode) map; erase]. "2 June 1990: des added the isNil check"
shrunkenWindow mode removeFromSuperMode.
shrunkenWindow mode release].
shrunkenWindow _ ShrunkenWindow window: self.
pos isNil | superM isNil
ifTrue: ["2 June 1990: des added the superM check"
shrunkenWindow mode origin: 50 @ 150]
ifFalse: [shrunkenWindow attachModeTo: superM at: pos]!
setUpTitleBar
"Shan 30 May 1990"
self titleBar: TitleBar new.
mode superMode isNil ifFalse: [self mode display]! !
!Window methodsFor: 'controller-msg'!
enterWindow: e
"Tell the title bar to highlight. Shan July 21, 1989"
titleBar mode highlight!
leaveWindow: e
"Tell the title bar to deHighlight. Shan July 21, 1989"
titleBar mode deHighlight! !
!Window methodsFor: 'MMS-initializations'!
setUpAppearance
"Shan June 6, 1989"
super setUpAppearance. "Shan July 21, 1989"
mode borderWidth: 2.
mode insideColor: Form white!
setUpController
"Very important!! The controllers of a window must be opaque.
Otherwise, unprocessed events will be sent to the window under it.
Shan June 6, 1989"
"Add the highlight when enter window. Shan July 21, 1989"
| ctrl erDict |
super setUpController.
ctrl _ mode controller.
erDict _ ctrl eventResponses deepCopy.
erDict at: #enterMode put: #enterWindow:.
erDict at: #leaveMode put: #leaveWindow:.
ctrl eventResponses: erDict! !
!Window methodsFor: 'initialize-release'!
initialize
"Shan June 7, 1989"
super initialize.
minimumSize _ 50 @ 50.
maximumSize _ Display extent.
"Default initial state is shrunken"
mode unMap.
self setUpTitleBar. "Shan 30 May 1990"
self setUpShrinkBox.
self setUpResizeBox.
self setUpShrunkenWindow! !
!Window methodsFor: 'private'!
title: t origin: org extent: ext
"Shan June 6, 1989"
self title: t.
mode origin: org extent: ext.
"self setUpTitleBar.
self setUpShrinkBox.
self setUpResizeBox.
self setUpShrunkenWindow Shan 30 May 1990"! !
!Window methodsFor: 'size'!
maximumSize
"Answer a point representing the maximum width and height of the receiver."
^maximumSize!
maximumSize: aPoint
"Set the argument, aPoint, to be the maximum width and height of the receiver."
maximumSize _ aPoint!
minimumSize
"Answer a point representing the minimum width and height of the receiver."
^minimumSize!
minimumSize: aPoint
"Set the argument, aPoint, to be the minimum width and height of the receiver."
minimumSize _ aPoint! !
!Window methodsFor: 'roaming'!
addHorizontalScrollBar
"Assume that applicationMode exists. Shan June 23, 1989"
| sBar wind rs |
wind _ mode window.
sBar _ RoamBox extent: wind width - 16 @ 18 clientMode: applicationMode.
sBar attachModeTo: mode at: 0 @ (wind bottom - sBar mode viewport height).
rs _ ResizeStyle new.
rs originX: #fixed.
rs extentY: #fixed.
rs cornerX: #fixed.
rs cornerY: #fixed.
sBar mode resizeStyle: rs.
applicationMode extent: applicationMode viewport extent - (0 @ (sBar mode viewport height -2))!
addVerticalScrollBar
"Assume that applicationMode exists. Shan June 23, 1989"
| sBar wind rs |
wind _ mode window.
sBar _ RoamBox extent: 18 @ (wind height - 16 - 26) clientMode: applicationMode.
sBar attachModeTo: mode at: wind right - sBar mode viewport width @ (wind top + 26).
rs _ ResizeStyle new.
rs originY: #fixed.
rs extentX: #fixed.
rs cornerX: #fixed.
rs cornerY: #fixed.
sBar mode resizeStyle: rs.
applicationMode extent: applicationMode viewport extent - (sBar mode viewport width - 2 @ 0)! !
!Window methodsFor: 'copying'!
duplicate
"Detach the icon of the window from rootMode. Shan September 5,
1989"
| c |
shrunkenWindow isNil ifTrue: [^super duplicate]. "Shan 13 June 1990"
shrunkenWindow mode removeFromSuperMode.
c _ super duplicate.
mode superMode notNil ifTrue: [shrunkenWindow attachModeTo: mode superMode].
^c! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
Window class
instanceVariableNames: ''!
!Window class methodsFor: 'instance creation'!
title: title
"Return a window with titlebar. Shan June 6, 1989"
^self title: title extent: 300@300!
title: title extent: ext
"Return a window with titlebar. Shan June 6, 1989"
^self title: title origin: 50@50 extent: ext!
title: title origin: org extent: ext
"Return a window with titlebar. Shan June 16, 1989"
^self new title: title origin: org extent: ext! !
!Window class methodsFor: 'testing'!
netTest
"Window netTest"
"Shan June 7, 1989"
| rMode w|
rMode _ RootMode new.
w _ Window title: 'Test Window' origin: 50@50 extent: 400 @ 400.
w shrinkPosition: 5@5.
w attachModeTo: rMode.
w applicationMode: Net new mode.
"Scrollbar must come after the application is set. Shan June 23, 1989"
w addVerticalScrollBar.
w addHorizontalScrollBar.
rMode startUp!
shadedTitleBarTest
"Window shadedTitleBarTest"
"Shan June 6, 1989"
| rMode w |
rMode _ RootMode new.
w _ Window title: 'Test Window' extent: 200 @ 200.
w attachModeTo: rMode at: 50 @ 50.
w shrunkenWindow attachModeTo: rMode at: 5 @ 5.
w initialOpen.
w titleBar: ShadedTitleBar new.
rMode startUp!
vanillaTest
"Window vanillaTest"
"Shan June 6, 1989"
| rMode w |
rMode _ RootMode new.
w _ Window title: 'Test Window' extent: 200 @ 200.
w attachModeTo: rMode at: 50 @ 50.
w shrunkenWindow attachModeTo: rMode at: 5 @ 5.
w initialOpen.
rMode startUp! !